package com.lys.enchantment.weapon;

import com.lys.effect.ModEffects;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSources;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

import java.util.List;

public class BloodthirstySwordEnchantment  extends Enchantment {

    public static final String BLOODTHIRSTY_SWORD_TIP_TRANSLATION_KEY ="bloodthirsty_sword_tip_translation_key";

    public BloodthirstySwordEnchantment(Rarity weight, EquipmentSlot... slotTypes) {
        super(weight,EnchantmentTarget.WEAPON , slotTypes);
    }

    @Override
    public int getMaxLevel() {
        return 3;
    }

    @Override
    public void onTargetDamaged(LivingEntity user, Entity target, int level) {
        DamageSources damageSources = user.getDamageSources();
        user.damage(damageSources.magic(),1);
        user.addStatusEffect(new StatusEffectInstance(ModEffects.MADNESS, 200, level, false, true, true));
    }

    public static void appendTooltip(List<Text> tooltip) {
        if (Screen.hasShiftDown()) {
            tooltip.add(Text.translatable("enchantment.moreenchantmentmod.bloodthirsty_sword").formatted(Formatting.RED));
            tooltip.add(Text.translatable(BLOODTHIRSTY_SWORD_TIP_TRANSLATION_KEY).formatted(Formatting.BLUE));
        } else {
            tooltip.add(Text.translatable("tip_translation_key").formatted(Formatting.GRAY));
        }
    }
}
